//go:build wireinject

package startup

import (
	"github.com/gin-gonic/gin"
	"github.com/google/wire"
	"webook/internal/repository"
	"webook/internal/repository/cache"
	"webook/internal/repository/dao"
	article2 "webook/internal/repository/dao/article"
	"webook/internal/service"
	"webook/internal/web"
)

func InitGin() *gin.Engine {
	wire.Build(
		// 初始化数据库连接
		InitDB, InitRedis,
		// dao层
		dao.NewUserDAO, article2.NewGORMArticleDAO,
		// cache层
		cache.NewUserCache, cache.NewCodeCache,
		// repo层
		repository.NewCodeRepository, repository.NewUserRepository, repository.NewCachedArticleRepository,
		// service层
		InitSMSService, service.NewSmsCodeService, service.NewUserService, InitWechatService, service.NewArticleService,
		// web层
		web.NewUserHandler, web.NewOauth2WechatHandler, web.NewJwtHandler, web.NewArticleHandler,
		// server层
		InitWebServer,
		// ratelimit
		InitRateLimiter,
		// 中间件层
		InitMiddlewares,
		// zap 层
		InitUserZap,
	)
	return new(gin.Engine)
}
